module cl {
	export class DieAction extends ActionPerformer {
		constructor() {
			super();
			this.type = 2;
			this.paramKeys = "[]";
			this.paramVals = "[]";
		}

		public accept() : void {
			// let vals = JSON.parse(this.paramVals);
			// let keys = JSON.parse(this.paramKeys);
			let troop = Campaign.troop[this.troopid];

			// 数据
			let forceTroopCache = troop.plane == 0 ? Campaign.force[troop.force].innerTroop : Campaign.force[troop.force].courtTroop;
			let pos1 = forceTroopCache.indexOf(this.troopid);
			if (pos1 >= 0){
				forceTroopCache.splice(pos1, 1);
			}
			let typeTroopCache = Campaign.troop_type[troop.troop_type].troop;
			let pos2 = typeTroopCache.indexOf(this.troopid);
			if (pos2 >= 0){
				typeTroopCache.splice(pos2, 1);
			}
			Campaign.troop_plane[this.troopid] = -1;
			troop.plane = -1;
			troop.move_remain = this.move_remain;
			Campaign.troop_map[troop.tid] = -1;
		}

		public acceptOnce() : void { 
			this.accept();
			MarchCommand.refreshDieTeam(this.troopid);
		}

		public duration() : number {
			return 850;
		}

		public play(map : CampaignPage) : void {
            // 看见路径周围
			let troopGroup = (Campaign.troop_plane[this.troopid] == 0 ? map.groupTroop : map.groupCourtTroop).getChildByName(String(this.troopid)) as eui.Group;
            AttackEffect.die(troopGroup, this.duration() - 50);
		}
	}
}